package com.ruoyi.file.utils;

import com.ruoyi.common.core.utils.HMACSHA256;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class UploadFileService {
    @Value("${file.appid}")
    private  String appid;
    @Value("${file.secret}")
    private  String secret;
    @Value("${file.time-out}")
    private  String timeOut;
    @Value("${file.download-url}")
    private  String downloadUrl;
    public  String getPathUrl(String fileId,String name){
        long ts = System.currentTimeMillis() / 1000;
        String sign = HMACSHA256.sign(appid + "," + ts + ',' + fileId + ',' + timeOut, secret);
        return String.format(downloadUrl,fileId,ts,timeOut,sign,name);
    }
}
